package com.yupi.yupicturebackend.constant;

import java.util.Arrays;
import java.util.List;
import java.util.Set;

/**
 * 文件相关常量
 *
 * @author yupi
 */
public interface FileConstant {

    /**
     * 文件大小限制
     */
    long ONE_MB = 1024 * 1024L;
    long MAX_FILE_SIZE = 2 * ONE_MB;
    long THUMBNAIL_THRESHOLD_SIZE = 20 * 1024L; // 20KB

    /**
     * 允许上传的图片格式
     */
    List<String> ALLOWED_IMAGE_FORMATS = Arrays.asList("jpeg", "jpg", "png", "webp", "gif");
    Set<String> ALLOWED_IMAGE_FORMATS_SET = Set.of("jpeg", "jpg", "png", "webp", "gif");

    /**
     * 图片处理相关常量
     */
    int DEFAULT_THUMBNAIL_WIDTH = 256;
    int DEFAULT_THUMBNAIL_HEIGHT = 256;
    int SCALE_PRECISION = 2; // 宽高比精度

    /**
     * 文件名相关常量
     */
    int UUID_LENGTH = 16;
    String DATE_FORMAT = "yyyy-MM-dd";
    String FILE_NAME_SEPARATOR = "_";
    String FILE_EXTENSION_SEPARATOR = ".";

    /**
     * 错误信息常量
     */
    String ERROR_FILE_EMPTY = "文件不能为空";
    String ERROR_FILE_TOO_LARGE = "文件大小不能超过 2MB";
    String ERROR_INVALID_FILE_TYPE = "不支持的文件类型";
    String ERROR_UPLOAD_FAILED = "文件上传失败";
    String ERROR_FILE_DELETE_FAILED = "临时文件删除失败";

    /**
     * 路径相关常量
     */
    String PATH_SEPARATOR = "/";
    String TEMP_FILE_PREFIX = "upload_";
}
